﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public static class DateTimeExtension
{
    public static int CompareDayTo(this DateTime date2, DateTime date)
    {
        long time = (date2.Ticks - date.Ticks) / 10000000;
        int dayNum = (int)time / (24 * 3600);
        return dayNum;
    }
    public static long CompareMillisecondTo(this DateTime date2, DateTime date)
    {
        long time = (date2.Ticks - date.Ticks) / TimeSpan.TicksPerMillisecond;
        return time;
    }
    public static long ToLongTime(this DateTime datetime)
    {
        long beginTicks = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddHours(7).Ticks;
        long longMiniseconds = (datetime.Ticks - beginTicks) / TimeSpan.TicksPerMillisecond;
        return longMiniseconds;
    }
    public static DateTime ToDate(this DateTime datetime)
    {

        return datetime.ToString("dd/MM/yyyy").ToDateTime();
    }
}

